package com.henghai.zhenxuan.ui.page.adapter;

import android.content.Context;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.henghai.zhenxuan.data.bean.RaiseBean;
import com.henghai.zhenxuan.databinding.AdapterRaiseItemBinding;
import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;

public class RaiseAdapter extends SimpleDataBindingAdapter<RaiseBean.RowsDTO, AdapterRaiseItemBinding> {
    private OnItemBtClickListener listener;

    public RaiseAdapter(Context context) {
        super(context, com.henghai.zhenxuan.R.layout.adapter_raise_item, DiffUtils.getInstance().getRaiseItemCallback());
    }

    @Override
    protected void onBindItem(AdapterRaiseItemBinding binding, RaiseBean.RowsDTO item, RecyclerView.ViewHolder holder) {
        binding.setRaise(item);
        binding.monitorTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onItemMonitorClick(item);
            }
        });
        binding.feedingTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onItmeFeedingClick(item);
            }
        });
    }

    public void setListener(OnItemBtClickListener listener) {
        this.listener = listener;
    }

    public interface OnItemBtClickListener {
        void onItemMonitorClick(RaiseBean.RowsDTO bean);

        void onItmeFeedingClick(RaiseBean.RowsDTO bean);
    }
}
